import request from '@/utils/request'

const personalApi = {
  userList: '/api/user',
  rolelist:'/api/role',
  // adduser:'/api/user'
}

class Service {
  /**
   *  @description GET 获取用户列表
   */
  static getUserList(data: object) {
    console.log(data)
    return request({
      url: `${personalApi.userList}?`,
      method: 'GET',
      json: true,
      params: data
    })
  }

    /**
   *  @description POST 添加用户列表
   */
     static AddUser(data: object) {
      console.log(data)
      return request({
        url: `${personalApi.userList}`,
        method: 'POST',
        json: true,
        data: data,
        // headers:{ "Content-Type": "multipart/form-data" }
      })
    }

    /**
   *  @description PATCH 修改用户列表
   */
     static UpdateUser(id,data: object) {
      console.log(data)
      return request({
        url: `${personalApi.userList}/${id}`,
        method: 'PATCH',
        json: true,
        data: data,
        // headers:{ "Content-Type": "multipart/form-data" }
      })
    }
  

  /**
   *  @description DELETE 删除用户
   */
  static DelUserInfo(info: Number) {
    return request({
      url: `${personalApi.userList}/${String(info)}`,
      method: 'DELETE',
      json: true
    })
  }

  /**
   *  @description DELETE 修改用户
   */
  static AmendUserInfo(data: object) {
    return request({
      url: personalApi.userList,
      method: 'PUT',
      json: true,
      data
    })
  }

  /**
   *  @description GET 获取角色列表
   */
   static getRoleList() {
    // console.log(data)
    return request({
      url: `${personalApi.rolelist}?`,
      method: 'GET',
      json: true,
      // params: data
    })
  }
}

export default Service
